import purchaseApi from "@/api/declaration/erp/purchaseApi"
import httpRequest from "@/config/axios/httpRequest"
import { PurchaseOrderModel } from "@/models/erp/PurchaseOrderModel"


// ERP 采购订单 API
export const PurchaseOrderApi = {
  // 查询采购订单分页
  getPurchaseOrderPage: async (params: any) => {
    return await httpRequest.get(purchaseApi.GetPurchaseOrderPage, params)
  },

  // 查询采购订单详情
  getPurchaseOrder: async (id: number) => {
    return await httpRequest.get(purchaseApi.GetPurchaseOrder, { params: { id} })
  },

  // 新增采购订单
  createPurchaseOrder: async (data: PurchaseOrderModel) => {
    return await httpRequest.post(purchaseApi.CreatePurchaseOrder, data)
  },

  // 修改采购订单
  updatePurchaseOrder: async (data: PurchaseOrderModel) => {
    return await httpRequest.post(purchaseApi.UpdatePurchaseOrder, data)
  },

  // 更新采购订单的状态
  updatePurchaseOrderStatus: async (id: number, status: number) => {
    return await httpRequest.put(purchaseApi.UpdatePurchaseOrderStatus, { id, status })
  },

  // 删除采购订单
  deletePurchaseOrder: async (ids: number[]) => {
    return await httpRequest.delete(purchaseApi.DeletePurchaseOrder, { params: { ids } })
  },

  // 导出采购订单 Excel
  exportPurchaseOrder: async (params: any) => {
    return await httpRequest.download(purchaseApi.ExportPurchaseOrder, params)
  }
}
